/**
 * 校园二手书交易平台 - 自定义样式
 * 作者：Inscode AI
 * 创建时间：2025年12月
 */

/* ==================== 全局样式 ==================== */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --info-color: #0dcaf0;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    
    --border-radius: 0.375rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: #f8f9fa;
}

/* ==================== 导航栏样式 ==================== */
.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    transition: var(--transition);
}

.navbar-nav .nav-link:hover {
    transform: translateY(-1px);
}

/* ==================== 卡片样式 ==================== */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
}

/* ==================== 书籍卡片样式 ==================== */
.book-card {
    cursor: pointer;
    overflow: hidden;
    height: 100%;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.book-card img {
    height: 200px;
    object-fit: cover;
    border-bottom: 1px solid #e9ecef;
}

.book-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--danger-color);
}

.book-original-price {
    font-size: 0.9rem;
    color: var(--secondary-color);
    text-decoration: line-through;
    margin-left: 0.5rem;
}

.book-condition {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.25rem;
    text-transform: uppercase;
}

/* 成色标签样式 */
.condition-new {
    background-color: #d1edff;
    color: #0c63e4;
}

.condition-like_new {
    background-color: #d1f2eb;
    color: #0f5132;
}

.condition-good {
    background-color: #fff3cd;
    color: #664d03;
}

.condition-fair {
    background-color: #f8d7da;
    color: #842029;
}

.condition-poor {
    background-color: #e2e3e5;
    color: #41464b;
}

.book-info {
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.book-info div {
    margin-bottom: 0.25rem;
}

/* ==================== 订单卡片样式 ==================== */
.order-card {
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
}

.order-header {
    background-color: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.order-body {
    padding: 1rem;
}

.order-status {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.25rem;
}

/* 订单状态样式 */
.status-pending {
    background-color: #fff3cd;
    color: #664d03;
}

.status-accepted {
    background-color: #d1f2eb;
    color: #0f5132;
}

.status-rejected {
    background-color: #f8d7da;
    color: #842029;
}

.status-completed {
    background-color: #d1edff;
    color: #0c63e4;
}

.status-cancelled {
    background-color: #e2e3e5;
    color: #41464b;
}

/* ==================== 图片上传样式 ==================== */
#imageUploadArea {
    border: 2px dashed #dee2e6;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    min-height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#imageUploadArea:hover {
    border-color: var(--primary-color);
    background-color: #f8f9fa;
}

#imageUploadArea.dragover {
    border-color: var(--primary-color);
    background-color: #e7f3ff;
}

.image-preview-item {
    position: relative;
    margin-bottom: 0.5rem;
}

.image-preview-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: var(--border-radius);
}

.btn-remove {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 50%;
    opacity: 0.8;
}

.btn-remove:hover {
    opacity: 1;
}

/* ==================== 模态框样式 ==================== */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    background-color: var(--primary-color);
    color: white;
    border-bottom: none;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.modal-footer {
    border-top: 1px solid #e9ecef;
}

/* ==================== 分页样式 ==================== */
.pagination {
    margin-bottom: 0;
}

.page-link {
    color: var(--primary-color);
    border: 1px solid #dee2e6;
}

.page-link:hover {
    color: var(--primary-color);
    background-color: #e7f3ff;
    border-color: #dee2e6;
}

.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ==================== 空状态样式 ==================== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--secondary-color);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h5 {
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

/* ==================== 警告消息样式 ==================== */
.alert {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.alert-success {
    background-color: #d1f2eb;
    color: #0f5132;
}

.alert-danger {
    background-color: #f8d7da;
    color: #842029;
}

.alert-warning {
    background-color: #fff3cd;
    color: #664d03;
}

.alert-info {
    background-color: #d1edff;
    color: #0c63e4;
}

/* ==================== 按钮样式 ==================== */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: var(--transition);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ==================== 表单样式 ==================== */
.form-control, .form-select {
    border-radius: var(--border-radius);
    border: 1px solid #ced4da;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-label {
    font-weight: 600;
    color: var(--dark-color);
}

/* ==================== 表格样式 ==================== */
.table {
    margin-bottom: 0;
}

.table th {
    background-color: #f8f9fa;
    font-weight: 600;
    border-top: none;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
}

/* ==================== 徽章样式 ==================== */
.badge {
    font-weight: 600;
    padding: 0.375rem 0.75rem;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .book-card img {
        height: 150px;
    }
    
    .book-title {
        font-size: 1rem;
    }
    
    .book-price {
        font-size: 1.1rem;
    }
    
    .order-card {
        margin-bottom: 0.75rem;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* ==================== 动画效果 ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* ==================== 工具类 ==================== */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bg-light-custom {
    background-color: #f8f9fa !important;
}

.border-dashed {
    border-style: dashed !important;
}

.border-2 {
    border-width: 2px !important;
}

/* ==================== 自定义滚动条 ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ==================== 加载动画 ==================== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==================== 打印样式 ==================== */
@media print {
    .navbar, .modal, .btn, .pagination {
        display: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}

/* ==================== 辅助功能 ==================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000;
    }
    
    .btn {
        border-width: 2px;
    }
}

/* 减少动画支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
